//
//  SendRequestViewController.m
//  huashiedu
//
//  Created by oceans on 2018/9/1.
//  Copyright © 2018年 hema. All rights reserved.
//

#import "SendRequestViewController.h"
#import "ThreeLevelLinkageModel.h"
#import "TipManager.h"
#import "Utility.h"
#import "HttpRequest.h"
#import "ShareModel.h"

@interface SendRequestViewController () <UITextFieldDelegate, UIPickerViewDelegate, UIPickerViewDataSource>

@property (strong, nonatomic) UIScrollView *scrollView;
@property (strong, nonatomic) UIButton *shengBtn;
@property (strong, nonatomic) UIButton *shiBtn;
@property (strong, nonatomic) UIButton *xianBtn;
@property (strong, nonatomic) UITextField *addressField;

@property (strong, nonatomic) UIButton *timeButton;

@property (strong, nonatomic) UIButton *lowAgeBtn;
@property (strong, nonatomic) UIButton *highAgeBtn;

@property (strong, nonatomic) UIButton *lowPeopleBtn;
@property (strong, nonatomic) UIButton *highPeopleBtn;

@property (strong, nonatomic) UITextField *contactName;
@property (strong, nonatomic) UITextField *contactNum;
@property (strong, nonatomic) UITextField *contactCode;

@property (weak, nonatomic) UITextField *currentField;

@property (strong, nonatomic) UIPickerView *areaPicker;
@property (strong, nonatomic) UIView *areaView;

@property (strong, nonatomic) NSArray <CityModel *> *citys;
@property (strong, nonatomic) NSArray <AreaModel *> *areas;
@property (assign, nonatomic) NSInteger provinceIndex;
@property (assign, nonatomic) NSInteger cityIndex;
@property (assign, nonatomic) NSInteger areaIndex;

@property (strong, nonatomic) UIView *dateView;
@property (strong, nonatomic) UIDatePicker *datePicker;
@property (copy, nonatomic) NSString *dateString;

@property (strong, nonatomic) UIView *ageView;
@property (strong, nonatomic) UIPickerView *agePicker;

@property (assign, nonatomic) NSInteger lowAge;
@property (assign, nonatomic) NSInteger highAge;

@property (strong, nonatomic) UIView *peopleView;
@property (strong, nonatomic) UIPickerView *peoplePicker;

@property (assign, nonatomic) NSInteger lowPeople;
@property (assign, nonatomic) NSInteger highPeople;

@property (strong, nonatomic) UIButton *getCodeButton;
@property (strong, nonatomic) NSTimer *timer;
@property (assign, nonatomic) double timertime;

@property (strong, nonatomic) NSMutableArray *categorys;
@end

@implementation SendRequestViewController

- (instancetype)init {
    self = [super init];
    if (self) {
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardDidShowNotification object:nil];
    }
    return self;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.automaticallyAdjustsScrollViewInsets = NO;
    self.categorys = [NSMutableArray array];
    [self setupView];
}

- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    [self.timer invalidate];
}

- (void)toClose {
    [self.navigationController dismissViewControllerAnimated:YES completion:nil];
}

- (void)setupView {
    
    self.view.backgroundColor = [UIColor whiteColor];
    self.navigationItem.title = @"发布活动";
    
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    button.frame = CGRectMake(0, 0, 44, 44);
    [button setImage:[UIImage imageNamed:@"chacha"] forState:UIControlStateNormal];
    button.titleLabel.font = [UIFont systemFontOfSize:15.0];
    [button setImageEdgeInsets:UIEdgeInsetsMake(5, 5, 5, 5)];
    [button addTarget:self action:@selector(toClose) forControlEvents:UIControlEventTouchUpInside];
    UIView *view = [[UIView alloc] initWithFrame:button.bounds];
    [view addSubview:button];
    
    UIBarButtonItem *right = [[UIBarButtonItem alloc] initWithCustomView:view];
    self.navigationItem.rightBarButtonItem = right;
    
    self.scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, XNavigationHeight, ScreenWidth, ScreenHeight - XNavigationHeight)];
    _scrollView.backgroundColor = [UIColor whiteColor];
    
    UIView *itemView = [[UIView alloc] initWithFrame:CGRectMake(30, 30, ScreenWidth - 60, 123)];
    UILabel *title = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 74, 33)];
    title.font = [UIFont systemFontOfSize:13.0];
    title.textColor = COLOR(44, 44, 44, 1);
    title.text = @"活动分类：";
    [itemView addSubview:title];
    
    NSArray *titles = @[@"书法绘画", @"英语口才", @"舞蹈跆拳",  @"音乐戏剧", @"国象围棋", @"科学探索", @"学科辅导", @"亲子活动"];
    CGFloat buttonWidth = (ScreenWidth - 60 - 74 - 20) / 3.0;
    for (NSInteger i = 0; i < titles.count; i ++) {
        
        UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
        button.titleLabel.font = [UIFont systemFontOfSize:13.0];
        [button setTitleColor:[UIColor colorWithRed:150/255.0 green:150/255.0 blue:150/255.0 alpha:1.0] forState:UIControlStateNormal];
        [button setTitleColor:[UIColor colorWithRed:1.0 green:36/255.0 blue:69/255.0 alpha:1.0] forState:UIControlStateSelected];
        button.layer.borderColor = [UIColor colorWithRed:225/255.0 green:225/255.0 blue:225/255.0 alpha:1.0].CGColor;
        button.layer.borderWidth = 0.5;
        button.layer.cornerRadius = 3.0;
        button.layer.masksToBounds = YES;
        button.tag = i+1;
        button.frame = CGRectMake(i % 3 * (buttonWidth + 10) + 74, i / 3 * 46, buttonWidth, 33);
        UIImage *sb = [UIImage imageNamed:@"button_background_image"];
        sb = [sb resizableImageWithCapInsets:UIEdgeInsetsMake(35, 35, 35, 35) resizingMode:UIImageResizingModeStretch];
        [button setBackgroundImage:sb forState:UIControlStateSelected];
        [button setTitle:titles[i] forState:UIControlStateNormal];
        [button addTarget:self action:@selector(buttonsPressed:) forControlEvents:UIControlEventTouchUpInside];
        [itemView addSubview:button];
    }
    
    [_scrollView addSubview:itemView];
    
    UIView *addressView = [[UIView alloc] initWithFrame:CGRectMake(30, CGRectGetMaxY(itemView.frame) + 17, ScreenWidth - 60, 82)];
    
    UILabel *addressTitle = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 74, 27)];
    addressTitle.font = [UIFont systemFontOfSize:13.0];
    addressTitle.textColor = COLOR(44, 44, 44, 1);
    addressTitle.text = @"活动地点：";
    [addressView addSubview:addressTitle];
    
    CGFloat btnWidth = (ScreenWidth - 134 - 20) / 3.0;
    self.shengBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    _shengBtn.frame = CGRectMake(74, 0, btnWidth, 27);
    _shengBtn.layer.borderColor = [UIColor colorWithRed:191/255.0 green:191/255.0 blue:191/255.0 alpha:1.0].CGColor;
    _shengBtn.layer.borderWidth = 0.5;
    _shengBtn.titleLabel.font = [UIFont systemFontOfSize:12.0];
    _shengBtn.layer.cornerRadius = 3.0;
    _shengBtn.layer.masksToBounds = YES;
    [_shengBtn setTitleColor:COLOR(108, 108, 108, 1) forState:UIControlStateNormal];
    [_shengBtn setTitle:@"请选择" forState:UIControlStateNormal];
    [_shengBtn setImage:[UIImage imageNamed:@"gray_triangle"] forState:UIControlStateNormal];
    [_shengBtn setTitleEdgeInsets:UIEdgeInsetsMake(0, -_shengBtn.imageView.bounds.size.width, 0, _shengBtn.imageView.bounds.size.width)];
    [_shengBtn setImageEdgeInsets:UIEdgeInsetsMake(0, _shengBtn.titleLabel.bounds.size.width + 5, 0, -_shengBtn.titleLabel.bounds.size.width)];
    [_shengBtn addTarget:self action:@selector(addressButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
    [addressView addSubview:_shengBtn];
    
    self.shiBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    _shiBtn.frame = CGRectMake(74 + btnWidth + 10, 0, btnWidth, 27);
    _shiBtn.layer.borderColor = [UIColor colorWithRed:191/255.0 green:191/255.0 blue:191/255.0 alpha:1.0].CGColor;
    _shiBtn.layer.borderWidth = 0.5;
    _shiBtn.titleLabel.font = [UIFont systemFontOfSize:12.0];
    _shiBtn.layer.cornerRadius = 3.0;
    _shiBtn.layer.masksToBounds = YES;
    [_shiBtn setTitleColor:COLOR(108, 108, 108, 1) forState:UIControlStateNormal];
    [_shiBtn setTitle:@"请选择" forState:UIControlStateNormal];
    [_shiBtn setImage:[UIImage imageNamed:@"gray_triangle"] forState:UIControlStateNormal];
    [_shiBtn setTitleEdgeInsets:UIEdgeInsetsMake(0, -_shiBtn.imageView.bounds.size.width, 0, _shiBtn.imageView.bounds.size.width)];
    [_shiBtn setImageEdgeInsets:UIEdgeInsetsMake(0, _shiBtn.titleLabel.bounds.size.width + 5, 0, -_shiBtn.titleLabel.bounds.size.width)];
    _shiBtn.tag = 1;
    [_shiBtn addTarget:self action:@selector(addressButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
    [addressView addSubview:_shiBtn];
    
    self.xianBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    _xianBtn.frame = CGRectMake(74 + 2*btnWidth + 20, 0, btnWidth, 27);
    _xianBtn.layer.borderColor = [UIColor colorWithRed:191/255.0 green:191/255.0 blue:191/255.0 alpha:1.0].CGColor;
    _xianBtn.layer.borderWidth = 0.5;
    _xianBtn.titleLabel.font = [UIFont systemFontOfSize:12.0];
    _xianBtn.layer.cornerRadius = 3.0;
    _xianBtn.layer.masksToBounds = YES;
    [_xianBtn setTitleColor:COLOR(108, 108, 108, 1) forState:UIControlStateNormal];
    [_xianBtn setTitle:@"请选择" forState:UIControlStateNormal];
    [_xianBtn setImage:[UIImage imageNamed:@"gray_triangle"] forState:UIControlStateNormal];
    [_xianBtn setTitleEdgeInsets:UIEdgeInsetsMake(0, -_xianBtn.imageView.bounds.size.width, 0, _xianBtn.imageView.bounds.size.width)];
    [_xianBtn setImageEdgeInsets:UIEdgeInsetsMake(0, _xianBtn.titleLabel.bounds.size.width + 5, 0, -_xianBtn.titleLabel.bounds.size.width)];
    _xianBtn.tag = 2;
    [_xianBtn addTarget:self action:@selector(addressButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
    [addressView addSubview:_xianBtn];
    
    self.addressField = [[UITextField alloc] initWithFrame:CGRectMake(74, 42, (ScreenWidth - 134), 40)];
    _addressField.delegate = self;
    _addressField.font = [UIFont systemFontOfSize:12.0];
    [_addressField setAttributedPlaceholder:[[NSAttributedString alloc] initWithString:@"请输入详细地址" attributes:@{NSFontAttributeName: [UIFont systemFontOfSize:12.0], NSForegroundColorAttributeName: [UIColor colorWithRed:178/255.0 green:178/255.0 blue:178/255.0 alpha:1.0]}]];
    _addressField.borderStyle = UITextBorderStyleRoundedRect;
    [addressView addSubview:_addressField];
    [_scrollView addSubview:addressView];
    
#pragma mark - timeView
    UIView *timeView = [[UIView alloc] initWithFrame:CGRectMake(30, CGRectGetMaxY(addressView.frame) + 15, ScreenWidth - 60, 27)];
    UILabel *timeTitle = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 74, 27)];
    timeTitle.font = [UIFont systemFontOfSize:13.0];
    timeTitle.textColor = COLOR(44, 44, 44, 1);
    timeTitle.text = @"计划时间：";
    [timeView addSubview:timeTitle];
    
    self.timeButton = [UIButton buttonWithType:UIButtonTypeCustom];
    _timeButton.frame = CGRectMake(74, 0, btnWidth*2, 27);
    _timeButton.layer.borderColor = [UIColor colorWithRed:191/255.0 green:191/255.0 blue:191/255.0 alpha:1.0].CGColor;
    _timeButton.layer.borderWidth = 0.5;
    _timeButton.titleLabel.font = [UIFont systemFontOfSize:12.0];
    _timeButton.layer.cornerRadius = 3.0;
    _timeButton.layer.masksToBounds = YES;
    [_timeButton setTitleColor:COLOR(108, 108, 108, 1) forState:UIControlStateNormal];
    [_timeButton setTitle:@"请选择" forState:UIControlStateNormal];
    [_timeButton setImage:[UIImage imageNamed:@"gray_triangle"] forState:UIControlStateNormal];
    [_timeButton setTitleEdgeInsets:UIEdgeInsetsMake(0, -_timeButton.imageView.bounds.size.width, 0, _timeButton.imageView.bounds.size.width)];
    [_timeButton setImageEdgeInsets:UIEdgeInsetsMake(0, _timeButton.titleLabel.bounds.size.width + 5, 0, -_timeButton.titleLabel.bounds.size.width)];
    [_timeButton addTarget:self action:@selector(timeButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
    [timeView addSubview:_timeButton];
    
    [_scrollView addSubview:timeView];
    
#pragma mark - ageView
    UIView *ageView = [[UIView alloc] initWithFrame:CGRectMake(30, CGRectGetMaxY(timeView.frame) + 17, ScreenWidth - 60, 27)];
    UILabel *ageTitle = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 74, 27)];
    ageTitle.font = [UIFont systemFontOfSize:13.0];
    ageTitle.textColor = COLOR(44, 44, 44, 1);
    ageTitle.text = @"参与年龄：";
    [ageView addSubview:ageTitle];
    
    self.lowAgeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    _lowAgeBtn.frame = CGRectMake(74, 0, btnWidth, 27);
    _lowAgeBtn.layer.borderColor = [UIColor colorWithRed:191/255.0 green:191/255.0 blue:191/255.0 alpha:1.0].CGColor;
    _lowAgeBtn.layer.borderWidth = 0.5;
    _lowAgeBtn.titleLabel.font = [UIFont systemFontOfSize:12.0];
    _lowAgeBtn.layer.cornerRadius = 3.0;
    _lowAgeBtn.layer.masksToBounds = YES;
    [_lowAgeBtn setTitleColor:COLOR(108, 108, 108, 1) forState:UIControlStateNormal];
    [_lowAgeBtn setTitle:@"请选择" forState:UIControlStateNormal];
    [_lowAgeBtn setImage:[UIImage imageNamed:@"gray_triangle"] forState:UIControlStateNormal];
    [_lowAgeBtn setTitleEdgeInsets:UIEdgeInsetsMake(0, -_lowAgeBtn.imageView.bounds.size.width, 0, _lowAgeBtn.imageView.bounds.size.width)];
    [_lowAgeBtn setImageEdgeInsets:UIEdgeInsetsMake(0, _lowAgeBtn.titleLabel.bounds.size.width + 5, 0, -_lowAgeBtn.titleLabel.bounds.size.width)];
    [_lowAgeBtn addTarget:self action:@selector(lowAgeButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
    [ageView addSubview:_lowAgeBtn];
    
    UIView *line = [[UIView alloc] initWithFrame:CGRectMake(CGRectGetMaxX(_lowAgeBtn.frame) + 10, 13.5, 6, 0.5)];
    line.backgroundColor = COLOR(44, 44, 44, 1);
    [ageView addSubview:line];
    
    self.highAgeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    _highAgeBtn.frame = CGRectMake(CGRectGetMaxX(line.frame) + 10, 0, btnWidth, 27);
    _highAgeBtn.layer.borderColor = [UIColor colorWithRed:191/255.0 green:191/255.0 blue:191/255.0 alpha:1.0].CGColor;
    _highAgeBtn.layer.borderWidth = 0.5;
    _highAgeBtn.titleLabel.font = [UIFont systemFontOfSize:12.0];
    _highAgeBtn.layer.cornerRadius = 3.0;
    _highAgeBtn.layer.masksToBounds = YES;
    [_highAgeBtn setTitleColor:COLOR(108, 108, 108, 1) forState:UIControlStateNormal];
    [_highAgeBtn setTitle:@"请选择" forState:UIControlStateNormal];
    [_highAgeBtn setImage:[UIImage imageNamed:@"gray_triangle"] forState:UIControlStateNormal];
    [_highAgeBtn setTitleEdgeInsets:UIEdgeInsetsMake(0, -_highAgeBtn.imageView.bounds.size.width, 0, _highAgeBtn.imageView.bounds.size.width)];
    [_highAgeBtn setImageEdgeInsets:UIEdgeInsetsMake(0, _highAgeBtn.titleLabel.bounds.size.width + 5, 0, -_highAgeBtn.titleLabel.bounds.size.width)];
    [_highAgeBtn addTarget:self action:@selector(highAgeButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
    [ageView addSubview:_highAgeBtn];
    [_scrollView addSubview:ageView];
    
#pragma mark - peopleView
    
    UIView *peopleView = [[UIView alloc] initWithFrame:CGRectMake(30, CGRectGetMaxY(ageView.frame) + 17, ScreenWidth - 60, 27)];
    UILabel *peopleTitle = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 74, 27)];
    peopleTitle.font = [UIFont systemFontOfSize:13.0];
    peopleTitle.textColor = COLOR(44, 44, 44, 1);
    peopleTitle.text = @"参与人数：";
    [peopleView addSubview:peopleTitle];
    
    self.lowPeopleBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    _lowPeopleBtn.frame = CGRectMake(74, 0, btnWidth, 27);
    _lowPeopleBtn.layer.borderColor = [UIColor colorWithRed:191/255.0 green:191/255.0 blue:191/255.0 alpha:1.0].CGColor;
    _lowPeopleBtn.layer.borderWidth = 0.5;
    _lowPeopleBtn.titleLabel.font = [UIFont systemFontOfSize:12.0];
    _lowPeopleBtn.layer.cornerRadius = 3.0;
    _lowPeopleBtn.layer.masksToBounds = YES;
    [_lowPeopleBtn setTitleColor:COLOR(108, 108, 108, 1) forState:UIControlStateNormal];
    [_lowPeopleBtn setTitle:@"请选择" forState:UIControlStateNormal];
    [_lowPeopleBtn setImage:[UIImage imageNamed:@"gray_triangle"] forState:UIControlStateNormal];
    [_lowPeopleBtn setTitleEdgeInsets:UIEdgeInsetsMake(0, -_lowPeopleBtn.imageView.bounds.size.width, 0, _lowPeopleBtn.imageView.bounds.size.width)];
    [_lowPeopleBtn setImageEdgeInsets:UIEdgeInsetsMake(0, _lowPeopleBtn.titleLabel.bounds.size.width + 5, 0, -_lowPeopleBtn.titleLabel.bounds.size.width)];
    [_lowPeopleBtn addTarget:self action:@selector(lowPeopleButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
    [peopleView addSubview:_lowPeopleBtn];
    
    UIView *line2 = [[UIView alloc] initWithFrame:CGRectMake(CGRectGetMaxX(_lowPeopleBtn.frame) + 10, 13.5, 6, 0.5)];
    line2.backgroundColor = COLOR(44, 44, 44, 1);
    [peopleView addSubview:line2];
    
    self.highPeopleBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    _highPeopleBtn.frame = CGRectMake(CGRectGetMaxX(line.frame) + 10, 0, btnWidth, 27);
    _highPeopleBtn.layer.borderColor = [UIColor colorWithRed:191/255.0 green:191/255.0 blue:191/255.0 alpha:1.0].CGColor;
    _highPeopleBtn.layer.borderWidth = 0.5;
    _highPeopleBtn.titleLabel.font = [UIFont systemFontOfSize:12.0];
    _highPeopleBtn.layer.cornerRadius = 3.0;
    _highPeopleBtn.layer.masksToBounds = YES;
    [_highPeopleBtn setTitleColor:COLOR(108, 108, 108, 1) forState:UIControlStateNormal];
    [_highPeopleBtn setTitle:@"请选择" forState:UIControlStateNormal];
    [_highPeopleBtn setImage:[UIImage imageNamed:@"gray_triangle"] forState:UIControlStateNormal];
    [_highPeopleBtn setTitleEdgeInsets:UIEdgeInsetsMake(0, -_highPeopleBtn.imageView.bounds.size.width, 0, _highPeopleBtn.imageView.bounds.size.width)];
    [_highPeopleBtn setImageEdgeInsets:UIEdgeInsetsMake(0, _highPeopleBtn.titleLabel.bounds.size.width + 5, 0, -_highPeopleBtn.titleLabel.bounds.size.width)];
    [_highPeopleBtn addTarget:self action:@selector(highPeopleButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
    [peopleView addSubview:_highPeopleBtn];
    [_scrollView addSubview:peopleView];
    
#pragma mark - contactView
    UIView *contactView = [[UIView alloc] initWithFrame:CGRectMake(30, CGRectGetMaxY(peopleView.frame) + 19, ScreenWidth - 30, 155)];
    
    UILabel *conTitle = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 74, 40)];
    conTitle.font = [UIFont systemFontOfSize:13.0];
    conTitle.textColor = COLOR(44, 44, 44, 1);
    conTitle.text = @"联系人：";
    [contactView addSubview:conTitle];
    
    self.contactName = [[UITextField alloc] initWithFrame:CGRectMake(74, 0, (ScreenWidth - 134), 40)];
    _contactName.delegate = self;
    _contactName.font = [UIFont systemFontOfSize:12.0];
    [_contactName setAttributedPlaceholder:[[NSAttributedString alloc] initWithString:@"请输入联系人称呼" attributes:@{NSFontAttributeName: [UIFont systemFontOfSize:12.0], NSForegroundColorAttributeName: [UIColor colorWithRed:178/255.0 green:178/255.0 blue:178/255.0 alpha:1.0]}]];
    _contactName.borderStyle = UITextBorderStyleRoundedRect;
    [contactView addSubview:_contactName];
    
    UILabel *phoneTitle = [[UILabel alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(conTitle.frame) + 17, 74, 40)];
    phoneTitle.font = [UIFont systemFontOfSize:13.0];
    phoneTitle.textColor = COLOR(44, 44, 44, 1);
    phoneTitle.text = @"联系方式：";
    [contactView addSubview:phoneTitle];
    
    self.contactNum = [[UITextField alloc] initWithFrame:CGRectMake(74, phoneTitle.frame.origin.y, (ScreenWidth - 134), 40)];
    _contactNum.delegate = self;
    _contactNum.font = [UIFont systemFontOfSize:12.0];
    [_contactNum setAttributedPlaceholder:[[NSAttributedString alloc] initWithString:@"请输入手机号码" attributes:@{NSFontAttributeName: [UIFont systemFontOfSize:12.0], NSForegroundColorAttributeName: [UIColor colorWithRed:178/255.0 green:178/255.0 blue:178/255.0 alpha:1.0]}]];
    _contactNum.borderStyle = UITextBorderStyleRoundedRect;
    [contactView addSubview:_contactNum];
    
    self.getCodeButton = [UIButton buttonWithType:UIButtonTypeCustom];
    _getCodeButton.backgroundColor = COLOR(227, 227, 227, 1);
    _getCodeButton.layer.cornerRadius = 3;
    _getCodeButton.layer.masksToBounds = YES;
    _getCodeButton.frame = CGRectMake(0, 0, 75, 30);
    [_getCodeButton setTitleColor:COLOR(163, 163, 163, 1) forState:UIControlStateNormal];
    _getCodeButton.titleLabel.font = [UIFont systemFontOfSize:11.0];
    [_getCodeButton setTitle:@"获取验证码" forState:UIControlStateNormal];
    [_getCodeButton addTarget:self action:@selector(getCode) forControlEvents:UIControlEventTouchUpInside];
    _contactNum.rightView = _getCodeButton;
    _contactNum.rightViewMode = UITextFieldViewModeAlways;
    
    UILabel *codeTitle = [[UILabel alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(phoneTitle.frame) + 17, 74, 40)];
    codeTitle.font = [UIFont systemFontOfSize:13.0];
    codeTitle.textColor = COLOR(44, 44, 44, 1);
    codeTitle.text = @"验证码：";
    [contactView addSubview:codeTitle];
    
    self.contactCode = [[UITextField alloc] initWithFrame:CGRectMake(74, codeTitle.frame.origin.y, (ScreenWidth - 134), 40)];
    _contactCode.delegate = self;
    _contactCode.font = [UIFont systemFontOfSize:12.0];
    [_contactCode setAttributedPlaceholder:[[NSAttributedString alloc] initWithString:@"请输入验证码" attributes:@{NSFontAttributeName: [UIFont systemFontOfSize:12.0], NSForegroundColorAttributeName: [UIColor colorWithRed:178/255.0 green:178/255.0 blue:178/255.0 alpha:1.0]}]];
    _contactCode.borderStyle = UITextBorderStyleRoundedRect;
    [contactView addSubview:_contactCode];
    
    UIButton *send = [UIButton buttonWithType:UIButtonTypeCustom];
    send.frame = CGRectMake(30, CGRectGetMaxY(contactView.frame) + 22, ScreenWidth - 60, 45);
    send.backgroundColor = COLOR(253, 119, 77, 1.0);
    [send setTitle:@"发布需求" forState:UIControlStateNormal];
    [send addTarget:self action:@selector(send) forControlEvents:UIControlEventTouchUpInside];
    send.titleLabel.font = [UIFont systemFontOfSize:17.0];
    send.layer.cornerRadius = 3.0;
    send.layer.masksToBounds = YES;
    [_scrollView addSubview:send];
    
    _scrollView.contentSize = CGSizeMake(ScreenWidth, send.frame.origin.y + 350);
    
    [_scrollView addSubview:contactView];
    
    [self.view addSubview:_scrollView];
}

- (UIPickerView *)peoplePicker {
    if (!_peoplePicker) {
        _peoplePicker = [[UIPickerView alloc] initWithFrame:CGRectMake(0, 30, ScreenWidth, 270)];
        _peoplePicker.tag = 2;
        _peoplePicker.delegate = self;
    }
    return _peoplePicker;
}

- (UIView *)peopleView {
    if (!_peopleView) {
        
        _peopleView = [[UIView alloc] initWithFrame:CGRectMake(0, ScreenHeight - 300, ScreenWidth, 300)];
        _peopleView.backgroundColor = [UIColor whiteColor];
        [_peopleView addSubview:self.peoplePicker];
        
        UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
        button.frame = CGRectMake(ScreenWidth - 60, 0, 50, 30);
        button.titleLabel.font = [UIFont systemFontOfSize:15.0];
        [button addTarget:self action:@selector(finishPeople) forControlEvents:UIControlEventTouchUpInside];
        [button setTitleColor:COLOR(155, 155, 155, 1) forState:UIControlStateNormal];
        [button setTitle:@"完成" forState:UIControlStateNormal];
        [_peopleView addSubview:button];
        
        [self.view addSubview:_peopleView];
    }
    return _peopleView;
}

- (void)finishPeople {
    
    if ([_peoplePicker selectedRowInComponent:0] > [_peoplePicker selectedRowInComponent:1]) {
        [TipManager showTip:@"最低人数不能大于最高人数"];
        return;
    }
    
    _lowPeople = [_peoplePicker selectedRowInComponent:0] + 1;
    _highPeople = [_peoplePicker selectedRowInComponent:1] + 1;
    
    [_lowPeopleBtn setTitle:[NSString stringWithFormat:@"%ld", _lowPeople] forState:UIControlStateNormal];
    [_highPeopleBtn setTitle:[NSString stringWithFormat:@"%ld", _highPeople] forState:UIControlStateNormal];
    
    [_lowPeopleBtn setTitleEdgeInsets:UIEdgeInsetsMake(0, -_lowPeopleBtn.imageView.bounds.size.width, 0, _lowPeopleBtn.imageView.bounds.size.width)];
    [_lowPeopleBtn setImageEdgeInsets:UIEdgeInsetsMake(0, _lowPeopleBtn.titleLabel.bounds.size.width + 5, 0, -_lowPeopleBtn.titleLabel.bounds.size.width)];
    
    [_highPeopleBtn setTitleEdgeInsets:UIEdgeInsetsMake(0, -_highPeopleBtn.imageView.bounds.size.width, 0, _highPeopleBtn.imageView.bounds.size.width)];
    [_highPeopleBtn setImageEdgeInsets:UIEdgeInsetsMake(0, _highPeopleBtn.titleLabel.bounds.size.width + 5, 0, -_highPeopleBtn.titleLabel.bounds.size.width)];
    
    _peopleView.hidden = YES;
}

- (UIPickerView *)agePicker {
    
    if (!_agePicker) {
        _agePicker = [[UIPickerView alloc] initWithFrame:CGRectMake(0, 30, ScreenWidth, 270)];
        _agePicker.tag = 1;
        _agePicker.delegate = self;
    }
    return _agePicker;
}

- (UIView *)ageView {
    if (!_ageView) {
        
        _ageView = [[UIView alloc] initWithFrame:CGRectMake(0, ScreenHeight - 300, ScreenWidth, 300)];
        _ageView.backgroundColor = [UIColor whiteColor];
        [_ageView addSubview:self.agePicker];
        
        UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
        button.frame = CGRectMake(ScreenWidth - 60, 0, 50, 30);
        button.titleLabel.font = [UIFont systemFontOfSize:15.0];
        [button addTarget:self action:@selector(finishAge) forControlEvents:UIControlEventTouchUpInside];
        [button setTitleColor:COLOR(155, 155, 155, 1) forState:UIControlStateNormal];
        [button setTitle:@"完成" forState:UIControlStateNormal];
        [_ageView addSubview:button];
        
        [self.view addSubview:_ageView];
    }
    return _ageView;
}

- (void)finishAge {
    
    if ([_agePicker selectedRowInComponent:0] > [_agePicker selectedRowInComponent:1]) {
        [TipManager showTip:@"最低年龄不能大于最高年龄"];
        return;
    }
    
    _lowAge = [_agePicker selectedRowInComponent:0] + 1;
    _highAge = [_agePicker selectedRowInComponent:1] + 1;
    
    [_lowAgeBtn setTitle:[NSString stringWithFormat:@"%ld", _lowAge] forState:UIControlStateNormal];
    [_highAgeBtn setTitle:[NSString stringWithFormat:@"%ld", _highAge] forState:UIControlStateNormal];
    
    [_lowAgeBtn setTitleEdgeInsets:UIEdgeInsetsMake(0, -_lowAgeBtn.imageView.bounds.size.width, 0, _lowAgeBtn.imageView.bounds.size.width)];
    [_lowAgeBtn setImageEdgeInsets:UIEdgeInsetsMake(0, _lowAgeBtn.titleLabel.bounds.size.width + 5, 0, -_lowAgeBtn.titleLabel.bounds.size.width)];
    
    [_highAgeBtn setTitleEdgeInsets:UIEdgeInsetsMake(0, -_highAgeBtn.imageView.bounds.size.width, 0, _highAgeBtn.imageView.bounds.size.width)];
    [_highAgeBtn setImageEdgeInsets:UIEdgeInsetsMake(0, _highAgeBtn.titleLabel.bounds.size.width + 5, 0, -_highAgeBtn.titleLabel.bounds.size.width)];
    
    _ageView.hidden = YES;
}

- (UIView *)dateView {
    if (!_dateView) {
        
        _dateView = [[UIView alloc] initWithFrame:CGRectMake(0, ScreenHeight - 300, ScreenWidth, 300)];
        _dateView.backgroundColor = [UIColor whiteColor];
        [_dateView addSubview:self.datePicker];
        
        UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
        button.frame = CGRectMake(ScreenWidth - 60, 0, 50, 30);
        button.titleLabel.font = [UIFont systemFontOfSize:15.0];
        [button addTarget:self action:@selector(finishDate) forControlEvents:UIControlEventTouchUpInside];
        [button setTitleColor:COLOR(155, 155, 155, 1) forState:UIControlStateNormal];
        [button setTitle:@"完成" forState:UIControlStateNormal];
        [_dateView addSubview:button];
        
        [self.view addSubview:_dateView];
    }
    return _dateView;
}

- (UIDatePicker *)datePicker {
    
    if (!_datePicker) {
        
        _datePicker = [[UIDatePicker alloc] initWithFrame:CGRectMake(0, 30, ScreenWidth, 270)];
        [_datePicker setDatePickerMode:UIDatePickerModeDateAndTime];
//        _datePicker.maximumDate = [NSDate date];
        _datePicker.locale = [NSLocale localeWithLocaleIdentifier:@"zh"];
    }
    return _datePicker;
}

- (void)finishDate {
    
    self.dateView.hidden = YES;
    NSDate *date = self.datePicker.date;
    NSDateFormatter *formate = [[NSDateFormatter alloc] init];
    [formate setDateFormat:@"yyyy-MM-dd HH:mm"];
    NSString *dateString = [formate stringFromDate:date];
    _dateString = dateString;
    [_timeButton setTitle:dateString forState:UIControlStateNormal];
    
    [_timeButton setTitleEdgeInsets:UIEdgeInsetsMake(0, -_timeButton.imageView.bounds.size.width, 0, _timeButton.imageView.bounds.size.width)];
    [_timeButton setImageEdgeInsets:UIEdgeInsetsMake(0, _timeButton.titleLabel.bounds.size.width + 5, 0, -_timeButton.titleLabel.bounds.size.width)];
}

- (UIPickerView *)areaPicker {
    
    if (!_areaPicker) {
        _areaPicker = [[UIPickerView alloc] initWithFrame:CGRectMake(0, 30, ScreenWidth, 270)];
        _areaPicker.delegate = self;
    }
    return _areaPicker;
}

- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView {
    if (pickerView.tag == 0) {
        return 3;
    }
    return 2;
}

- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component {
    
    if (pickerView.tag == 0) {
        
        if (component == 0) {
            return 31;
        }else if (component == 1) {
            return _citys.count;
        }else {
            return _areas.count;
        }
    }else if (pickerView.tag == 1) {
        return 79;
    }
    return 1000;
}

- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component {
    if (pickerView.tag == 0) {
        if (component == 0) {
            return [ThreeLevelLinkageModel shared].provinces[row].province_name;
        }else if (component == 1) {
            return self.citys[row].city_name;
        }else {
            return self.areas[row].area_name;
        }
    }
    return [NSString stringWithFormat:@"%ld", row + 1];
}

- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component {
    
    if (pickerView.tag == 0) {
        
        if (component == 2) {
            self.areaIndex = row;
        }else if (component == 1) {
            if (row == self.cityIndex) {
                return;
            }
            _cityIndex = row;
            _areaIndex = 0;
            __weak typeof(self) weakself = self;
            [[ThreeLevelLinkageModel shared] didSelectCityAtIndex:_citys[row].city_number areaData:^(NSMutableArray<AreaModel *> *dataArray) {
                weakself.areas = dataArray;
                [weakself.areaPicker reloadComponent:2];
                [weakself.areaPicker selectRow:0 inComponent:2 animated:NO];
            }];
        }else {
            if (row == _provinceIndex) {
                return;
            }
            _provinceIndex = row;
            _cityIndex = 0;
            _areaIndex = 0;
            __weak typeof(self) weakself = self;
            [[ThreeLevelLinkageModel shared] didSelectProvinceAtIndex:row cityData:^(NSMutableArray<CityModel *> *dataArray) {
                weakself.citys = dataArray;
                [weakself.areaPicker reloadComponent:1];
                [weakself.areaPicker selectRow:0 inComponent:1 animated:NO];
            } areaData:^(NSMutableArray<AreaModel *> *dataArray) {
                weakself.areas = dataArray;
                [weakself.areaPicker reloadComponent:2];
                [weakself.areaPicker selectRow:0 inComponent:2 animated:NO];
            }];
        }
    }
}

- (UIView *)areaView {
    if (!_areaView) {
        _areaView = [[UIView alloc] initWithFrame:CGRectMake(0, ScreenHeight - 300, ScreenWidth, 300)];
        _areaView.backgroundColor = [UIColor whiteColor];
        [_areaView addSubview:self.areaPicker];
        
        UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
        button.frame = CGRectMake(ScreenWidth - 60, 0, 50, 30);
        button.titleLabel.font = [UIFont systemFontOfSize:15.0];
        [button addTarget:self action:@selector(finishArea) forControlEvents:UIControlEventTouchUpInside];
        [button setTitleColor:COLOR(155, 155, 155, 1) forState:UIControlStateNormal];
        [button setTitle:@"完成" forState:UIControlStateNormal];
        [_areaView addSubview:button];
        
        [self.view addSubview:_areaView];
    }
    return _areaView;
}

- (void)finishArea {
    
    _areaView.hidden = YES;
    NSString *province = [ThreeLevelLinkageModel shared].provinces[_provinceIndex].province_name;
    NSString *city = _citys[_cityIndex].city_name;
    NSString *area = _areas[_areaIndex].area_name;
    [self.shengBtn setTitle:province forState:UIControlStateNormal];
    [self.shiBtn setTitle:city forState:UIControlStateNormal];
    [self.xianBtn setTitle:area forState:UIControlStateNormal];
    
    [_shengBtn setTitleEdgeInsets:UIEdgeInsetsMake(0, -_shengBtn.imageView.bounds.size.width, 0, _shengBtn.imageView.bounds.size.width)];
    [_shengBtn setImageEdgeInsets:UIEdgeInsetsMake(0, _shengBtn.titleLabel.bounds.size.width + 5, 0, -_shengBtn.titleLabel.bounds.size.width)];
    
    [_shiBtn setTitleEdgeInsets:UIEdgeInsetsMake(0, -_shiBtn.imageView.bounds.size.width, 0, _shiBtn.imageView.bounds.size.width)];
    [_shiBtn setImageEdgeInsets:UIEdgeInsetsMake(0, _shiBtn.titleLabel.bounds.size.width + 5, 0, -_shiBtn.titleLabel.bounds.size.width)];
    
    [_xianBtn setTitleEdgeInsets:UIEdgeInsetsMake(0, -_xianBtn.imageView.bounds.size.width, 0, _xianBtn.imageView.bounds.size.width)];
    [_xianBtn setImageEdgeInsets:UIEdgeInsetsMake(0, _xianBtn.titleLabel.bounds.size.width + 5, 0, -_xianBtn.titleLabel.bounds.size.width)];
}

- (void)keyboardWillShow:(NSNotification*)noti {
    
    CGRect textFrame = [_currentField convertRect:_currentField.bounds toView:self.view];
    NSLog(@"-------------------%f", [[noti.userInfo objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue].origin.y);
    if (CGRectGetMaxY(textFrame) > [[noti.userInfo objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue].origin.y) {
        [_scrollView setContentOffset:CGPointMake(0, (CGRectGetMaxY(textFrame) - [[noti.userInfo objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue].origin.y)) animated:NO];
    }
}

- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField {
    self.currentField = textField;
    return YES;
}

- (void)buttonsPressed:(UIButton*)sender {
    
    sender.selected = !sender.isSelected;
    if ([_categorys containsObject:[NSNumber numberWithInteger:sender.tag]]) {
        [_categorys removeObject:[NSNumber numberWithInteger:sender.tag]];
    }else {
        [_categorys addObject:[NSString stringWithFormat:@"%ld", sender.tag]];
    }
    if (sender.selected) {
        sender.layer.borderColor = [UIColor colorWithRed:1.0 green:94/255.0 blue:119/255.0 alpha:1.0].CGColor;
    }else {
        sender.layer.borderColor = [UIColor colorWithRed:225/255.0 green:225/255.0 blue:225/255.0 alpha:1.0].CGColor;
    }
}

- (void)addressButtonPressed:(UIButton*)sender {
    
    __weak typeof(self) weakself = self;
    if (_citys == nil) {
        [[ThreeLevelLinkageModel shared] didSelectProvinceAtIndex:_provinceIndex cityData:^(NSMutableArray<CityModel *> *dataArray) {
            weakself.citys = dataArray;
            if (weakself.areas == nil) {
                [[ThreeLevelLinkageModel shared] didSelectCityAtIndex:weakself.citys[0].city_number areaData:^(NSMutableArray<AreaModel *> *dataArray) {
                    weakself.areas = dataArray;
                }];
            }
        } areaData:nil];
    }
    
    if (_areaView && _areaView.hidden == NO) {
        _areaView.hidden = YES;
    }else {
        if (_ageView && _ageView.hidden == NO) {
            _ageView.hidden = YES;
        }
        if (_dateView && _dateView.hidden == NO) {
            _dateView.hidden = YES;
        }
        if (_peopleView && _peopleView.hidden == NO) {
            _peopleView.hidden = YES;
        }
        [self.view endEditing:YES];
        self.areaView.hidden = NO;
    }
}

- (void)timeButtonPressed:(UIButton *)sender {
    self.dateView.hidden = NO;
    if (_ageView && _ageView.hidden == NO) {
        _ageView.hidden = YES;
    }
    if (_areaView && _areaView.hidden == NO) {
        _areaView.hidden = YES;
    }
    if (_peopleView && _peopleView.hidden == NO) {
        _peopleView.hidden = YES;
    }
    [self.view endEditing:YES];
}

- (void)lowAgeButtonPressed:(UIButton *)sender {
    
    if (_dateView && _dateView.hidden == NO) {
        _dateView.hidden = YES;
    }
    if (_areaView && _areaView.hidden == NO) {
        _areaView.hidden = YES;
    }
    if (_peopleView && _peopleView.hidden == NO) {
        _peopleView.hidden = YES;
    }
    [self.view endEditing:YES];
    self.ageView.hidden = NO;
}

- (void)highAgeButtonPressed:(UIButton *)sender {
    
    if (_dateView && _dateView.hidden == NO) {
        _dateView.hidden = YES;
    }
    if (_areaView && _areaView.hidden == NO) {
        _areaView.hidden = YES;
    }
    if (_peopleView && _peopleView.hidden == NO) {
        _peopleView.hidden = YES;
    }
    [self.view endEditing:YES];
    self.ageView.hidden = NO;
}

- (void)lowPeopleButtonPressed:(UIButton *)sender {
    
    if (_dateView && _dateView.hidden == NO) {
        _dateView.hidden = YES;
    }
    if (_areaView && _areaView.hidden == NO) {
        _areaView.hidden = YES;
    }
    if (_ageView && _ageView.hidden == NO) {
        _ageView.hidden = YES;
    }
    [self.view endEditing:YES];
    self.peopleView.hidden = NO;
}

- (void)highPeopleButtonPressed:(UIButton *)sender {
    
    if (_dateView && _dateView.hidden == NO) {
        _dateView.hidden = YES;
    }
    if (_areaView && _areaView.hidden == NO) {
        _areaView.hidden = YES;
    }
    if (_ageView && _ageView.hidden == NO) {
        _ageView.hidden = YES;
    }
    [self.view endEditing:YES];
    self.peopleView.hidden = NO;
}

- (void)getCode {
    
    if ([Utility checkMobile:_contactNum.text]) {
        [self.view endEditing:YES];
        _timertime = 60;
        [self startTimer];
        __weak typeof(self) weakself = self;
        [[UserModel shared] getCodeWithPhoneNumber:_contactNum.text scope:@"publish" successBlock:nil failedBlock:^{
            [weakself stopTimer];
        }];
        
    }
}

- (void)startTimer {
    
    _getCodeButton.enabled = NO;
    [_getCodeButton setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
    [_getCodeButton setTitle:[NSString stringWithFormat:@"(%.0f)秒后可重发", _timertime] forState:UIControlStateNormal];
    self.timer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(timerMethod) userInfo:nil repeats:YES];
}

- (void)timerMethod {
    
    if (_timertime <= 0) {
        [_getCodeButton setTitleColor:COLOR(235, 86, 0, 1) forState:UIControlStateNormal];
        [_getCodeButton setTitle:@"获取验证码" forState:UIControlStateNormal];
        _getCodeButton.enabled = YES;
        [self.timer invalidate];
        return;
    }
    _timertime = _timertime - 1;
    [_getCodeButton setTitle:[NSString stringWithFormat:@"(%.0f)秒后可重发", _timertime] forState:UIControlStateNormal];
}

- (void)stopTimer {
    [_getCodeButton setTitleColor:COLOR(235, 86, 0, 1) forState:UIControlStateNormal];
    [_getCodeButton setTitle:@"获取验证码" forState:UIControlStateNormal];
    _getCodeButton.enabled = YES;
    [self.timer invalidate];
}

- (void)send {
    
    NSMutableDictionary *paras = [NSMutableDictionary dictionary];
    
    if (_categorys.count == 0) {
        [TipManager showTip:@"请选择课程分类"];
        return;
    }
    NSMutableString *categorys = [NSMutableString string];
    for (NSString *number in _categorys) {
        [categorys appendString:number];
        [categorys appendString:@","];
    }
    [paras setObject:categorys forKey:@"categorys"];
    
    if (_citys == nil || _areas == nil) {
        [TipManager showTip:@"请选择地址"];
        return;
    }
    NSString *province = [ThreeLevelLinkageModel shared].provinces[_provinceIndex].province_number;
    NSString *city = _citys[_cityIndex].city_number;
    NSString *district = _areas[_areaIndex].area_number;
    [paras setObject:province forKey:@"province"];
    [paras setObject:city forKey:@"city"];
    [paras setObject:district forKey:@"district"];
    
    if (_addressField.text.length == 0) {
        [TipManager showTip:@"请输入地址"];
        return;
    }
    NSString *address_detail = _addressField.text;
    [paras setObject:address_detail forKey:@"address_detail"];
    
    if (_dateString == nil || _dateString.length == 0) {
        [TipManager showTip:@"请选择时间"];
        return;
    }
    [paras setObject:_dateString forKey:@"begin_date"];
    
    if (_lowAge == 0 || _highAge == 0) {
        [TipManager showTip:@"请选择年龄"];
        return;
    }
    [paras setObject:[NSNumber numberWithInteger:_lowAge] forKey:@"age_min"];
    [paras setObject:[NSNumber numberWithInteger:_highAge] forKey:@"age_max"];
    
    if (_lowPeople == 0 || _highPeople == 0) {
        [TipManager showTip:@"请选择人数"];
        return;
    }
    [paras setObject:[NSNumber numberWithInteger:_lowPeople] forKey:@"limit_min"];
    [paras setObject:[NSNumber numberWithInteger:_highPeople] forKey:@"limit_max"];
    
    if (_contactName.text.length == 0) {
        [TipManager showTip:@"请填写联系人"];
        return;
    }
    [paras setObject:_contactName.text forKey:@"contact"];
    
    if (![Utility checkMobile:_contactNum.text]) {
        return;
    }
    [paras setObject:_contactNum.text forKey:@"mobile"];
    
    if (_contactCode.text.length == 0) {
        [TipManager showTip:@"请输入验证码"];
        return;
    }
    [paras setObject:_contactCode.text forKey:@"code"];
    
    [self.view endEditing:YES];
    __weak typeof(self) weakself = self;
    [HttpRequest postURL:kcreate_activity paras:paras showProgress:NO successful:^(id  _Nullable result) {
        NSLog(@"%@", result);
        if ([result[@"data"][@"status"] boolValue] == YES) {
            [weakself.navigationController dismissViewControllerAnimated:YES completion:^{
                [[ShareModel shared] showCreateSuccessView:result[@"data"][@"message"]];
            }];
        }else {
            [TipManager showTip:result[@"data"][@"message"]];
        }
    } failed:nil];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}

@end
